package com.aiyige.page.publish.selectinterest.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by usera on 2017/11/6.
 */

public class PublishIndustryItem implements Parcelable {
    String title;
    String id;
    boolean selected;
    List<PublishInterestItem> publishInterestItemList;

    public PublishIndustryItem() {
    }

    private PublishIndustryItem(Builder builder) {
        setTitle(builder.title);
        setId(builder.id);
        setSelected(builder.selected);
        setPublishInterestItemList(builder.publishInterestItemList);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public List<PublishInterestItem> getPublishInterestItemList() {
        return publishInterestItemList;
    }

    public void setPublishInterestItemList(List<PublishInterestItem> publishInterestItemList) {
        this.publishInterestItemList = publishInterestItemList;
    }


    public static final class Builder {
        private String title;
        private String id;
        private boolean selected;
        private List<PublishInterestItem> publishInterestItemList;

        private Builder() {
            title = "";
            id = "";
            selected = false;
            publishInterestItemList = new LinkedList<>();
        }

        public Builder title(String title) {
            this.title = title == null ? "" : title;
            return this;
        }

        public Builder id(String id) {
            this.id = id == null ? "" : id;
            return this;
        }

        public Builder selected(boolean selected) {
            this.selected = selected;
            return this;
        }

        public Builder publishInterestItemList(List<PublishInterestItem> publishInterestItemList) {
            this.publishInterestItemList = publishInterestItemList;
            return this;
        }

        public PublishIndustryItem build() {
            return new PublishIndustryItem(this);
        }
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.title);
        dest.writeString(this.id);
    }

    protected PublishIndustryItem(Parcel in) {
        this.title = in.readString();
        this.id = in.readString();
    }

    public static final Parcelable.Creator<PublishIndustryItem> CREATOR = new Parcelable.Creator<PublishIndustryItem>() {
        @Override
        public PublishIndustryItem createFromParcel(Parcel source) {
            return new PublishIndustryItem(source);
        }

        @Override
        public PublishIndustryItem[] newArray(int size) {
            return new PublishIndustryItem[size];
        }
    };
}
